package com.instalinks.android.apps.smspostservice.tasks;

import com.instalinks.android.apps.smspostservice.HomeActivity;
import com.instalinks.android.apps.smspostservice.helper.AppConfig;
import com.instalinks.android.lib.AppHelper;
import com.instalinks.android.lib.ApplicationNotifications;

import android.content.Context;
import android.os.AsyncTask;

public class WebSmsTask extends AsyncTask<Void, Void, Void> {

	private AppConfig appCfg;
	private Context context;
	private String phoneNumbers;
	private String message;

	public WebSmsTask(Context context, String message, String phoneNumbers) {
		appCfg = new AppConfig(context);
		this.context = context;
		this.phoneNumbers = phoneNumbers;
		this.message = message;
	}

	@Override
	protected Void doInBackground(Void... params) {
		AppHelper.sendMultipleSms(context, phoneNumbers, message, true);
		
		try{
			appCfg.setWebSmsCount(appCfg.getWebSmsCount()+1);
		}catch(Exception e){}
		
		return null;
	}

	@Override
	protected void onPostExecute(Void voids) {
		ApplicationNotifications appNotifications = appCfg
				.getExternalNotificationInstance();

		appNotifications.notify("Web SMS Request Processed",
				HomeActivity.class.getName());
	}

}
